<template>
  <div ref="myChart" class="line-chart" />
</template>
<script >
import * as echarts from 'echarts'
export default {
  name: 'CircleChart',
  props: ['data', 'title', 'set'],
  data() {
    return {

    }
  },
  mounted() {
    this.chartRun()
  },
  methods: {
    chartRun() {
      const myChart = echarts.init(this.$refs.myChart)
      window.addEventListener('resize', myChart.resize)

      const that = this

      const option = {
        title: {
          text: that.title,
          left: 'center',
          textStyle: {
            color: that.set.titleColor
          }
        },
        tooltip: {
          trigger: 'item'
        },
        color: ['#fc8251', '#5470c6', '#9A60B4', '#ef6567', '#f9c956', '#3BA272'],
        series: [
          {
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            // itemStyle: {
            //     borderRadius: 30,
            //     borderColor: 'rgba(255,255,255,0.3)',
            //     borderWidth: 20
            // },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 28,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: that.data

          }
        ]
      }
      myChart.setOption(option)
    }
  }
}
</script>
<style scoped>
.line-chart{
 width: 100%;
 flex: 1;
 }
</style>
